﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Authentication;
using System.Web;
using System.Web.Mvc;
using Quester.Other;

namespace Quester.Controllers
{
    public class HomeController : Controller
    {
        FileLoger loger = new FileLoger();

        public ActionResult Index()
        {
            loger.WriteLog("In Home/Index");
            
            if(Request.IsAuthenticated)
            {
                if(User.IsInRole("Student"))
                {
                    return RedirectToAction("Index", "Student");
                }
                else if(User.IsInRole("Teacher"))
                {
                    return RedirectToAction("Index", "Teacher");
                }
                else if(User.IsInRole("Admin"))
                {
                    return RedirectToAction("Index", "Admin");
                }
                else
                {
                    throw new AuthenticationException("Invalid user role");
                }
            }
            else
            {
                return RedirectToAction("LogOn", "Account");
            }

        }

        public ActionResult About()
        {
            return View();
        }
    }
}
